home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group00b.txt
/
000141_icon-group-sender_Fri Nov 3 07:43:22 2000.msg
< prev
next >
Wrap
Internet Message Format
|
2001-01-03
|
3KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id eA3Eg3A27420
for icon-group-addresses; Fri, 3 Nov 2000 07:42:03 -0700 (MST)
Message-Id: <200011031442.eA3Eg3A27420@baskerville.CS.Arizona.EDU>
Date: Thu, 02 Nov 2000 19:49:30 -0600
From: gep2@terabites.com
Subject: Re: How to "declare" a string?
To: icon-group@cs.arizona.edu
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1970
>> best I can tell, it is choking because UPPER has not been "declared".
> I am a *total* newbie, but I may have an answer to this one
(Icon programmer please correct this if wrong)
Icon will extract as much information from your statements as possible.
> so, if you initialize a variable like this:
> i := 0
> it will not need an
> i : INTEGER to figure it out, it knows that 0 is an integer, and will declare
i implicitely.
Not really. There is no "declaring" that i IS an integer (in any lasting
sense!). In fact i is simply a variable and it can contain an integer at one
moment, a string the next and a real at some later time. There is no durable
typing of any user-defined variables in Icon.
That said, Icon *does* keep careful track of what type each variable contains at
any given instant, so that it can be converted as necessary for whatever
operation might require that.
> the same with a string:
> s := ""
> will implicitely declare s to be string type.
Again, it merely tells Icon that *now* the variable s happens to contain a
string. You can subsequently execute:
s := "435" + 27.2 + 6 + '12'
(adding a string, a real, an integer and a character set variable) and the
result will be that the variable s will now contain a real.
> If in the start of your program, you set
> UPPER := ""
> you might solve an 'undeclared' reference ...
No. All variables default (in the absence of a prior declaration to the
contrary in some specific situations like the unassigned elements of tables
where I think you can specify a different default) to be a null string. Since
that is the default value, assigning it a (redundant) null string as the value
won't change anything.
Gordon Peterson
http://personal.terabites.com/
Support the Anti-SPAM Amendment! Join at http://www.cauce.org/
12/19/98: the day the Conservatives demonstrated their scorn for their
fraudulent sham of representative government. Voters, remember it!